namespace Collaboris.Saf.Actions.Wss.Tests.Generated
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI.WebControls.WebParts;

    using Engine.Report;

    using Microsoft.SharePoint.WebPartPages;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Saf.Tests;
    using Entities;

    using SharePoint.Wss.Files;
    using SharePoint.Wss.Lists;
    using SharePoint.Wss.WebParts;

    using Utils;

    using WebPart;

    using WebPart=Microsoft.SharePoint.WebPartPages.WebPart;

    [TestClass]
    public class SetWebPartPropertiesTest
    {
        [TestMethod]
        public void SetWebPartProperties_Test()
        {
            WSSTestAssistant<SetWebPartProperties, WebPartPropertiesInfo> setwebpartproperties =
                    new WSSTestAssistant<SetWebPartProperties, WebPartPropertiesInfo>(TestEnvironment.PublishingSite,
                        "SetWebPartPropertiesTestWeb", "BLANKINTERNET#0");

            using (setwebpartproperties)
            {
                // ok lets add a list view web part to the page...
                Guid listGuid = SPListHelper.GetListGuid(setwebpartproperties.TestWeb, "Pages");

                ListViewWebPart listViewWebPart = new ListViewWebPart();
                listViewWebPart.ListName = listGuid.ToString("B").ToUpper();
                listViewWebPart.ID = "MyListViewWebPart";
                listViewWebPart.Title = "MyListViewWebPart Title";

                SPFileHelper.CheckOutFile(setwebpartproperties.TestWeb.Url + @"/Pages/default.aspx");

                List<WebPart> webParts = new List<WebPart>() { listViewWebPart };
                SPWebPartHelper.AddWebParts(setwebpartproperties.TestWeb, "pages", "default.aspx", webParts, "TopZone", true, PersonalizationScope.Shared);

                setwebpartproperties.FirstEntity.WebPartID = listViewWebPart.ID;

                //SerializableObjectDictionary<string> dict = new SerializableObjectDictionary<string>();
                //dict.Add("HelpUrl", "HelpUrl");

                //setwebpartproperties.FirstEntity.Properties = dict;

                // now lets go and set the props.
                MacroReport doReport = setwebpartproperties.DoMacro();

                ListViewWebPart newWebbie = (ListViewWebPart)SPWebPartHelper.GetWebPartFromPage(
                                                 setwebpartproperties.TestWeb, @"/Pages/default.aspx", listViewWebPart.ID, PersonalizationScope.Shared);

                Assert.IsNotNull(newWebbie);
                Assert.IsTrue(newWebbie.HelpUrl == "http://www.yoursite.com/help");
            }
        }

    }
}
